package com.zzy.demo.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;


/**
 * 
 * @author guokaige
 *
 */
public class FastJsonUtil {
	 

	/**
	 * 转换json字符串 JSON也是一种序列化。
	 * 
	 * @param object
	 * @return
	 */
	public static String fastJsonSerialize(Object object) {
		return JSON.toJSONString(object, SerializerFeature.DisableCircularReferenceDetect);
	}

	/**
	 * 字符串转对象
	 * 
	 * @param object
	 * @param classOfT
	 * @return
	 */
	public static <T> T unFastJsonSerialize(String object, Class<T> classOfT) {
		T t = null;
		try {
			t = JSON.parseObject(object, classOfT);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return t;
	}

	

}